package algotithm.leetcode.dp.hot.test70;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/9-15:57
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int n = 3;
        int i = solution.climbStairs(n);
        System.out.println(i);
    }

    public int climbStairs(int n) {
       int a = 0, b = 0;
       int sum = 1;
       for (int i = 1; i <= n; i++) {
           a = b;
           b = sum;
           sum = a + b;
       }
       return sum;
    }
//    public int climbStairs(int n) {
//       int[] dp = new int[n+1];
//       dp[0] = 1;
//       dp[1] = 1;
//       for (int i = 2; i <= n; i++) {
//           dp[i] = dp[i-1] + dp[i-2];
//       }
//       return dp[n];
//    }

}
